package com.qdlc.p2p.dal.util;

import com.qdlc.p2p.common.constant.UserNature;
import com.qdlc.p2p.common.constant.UserType;
import com.qdlc.p2p.dal.dto.UserCache;

public class UserTypeUtils {

	/**
	 * 判断是否是投资人
	 * @param userId
	 * @return
	 */
	public static boolean isInvestor(long userId){
		UserCache userCache = UserUtils.getUserCacheByUserId(userId);
		return userCache.getUserType() == UserType.INVESTOR;
	}
	
	/**
	 * 判断是否是借款人
	 * @param userId
	 * @return
	 */
	public static boolean isBorrower(long userId){
		UserCache userCache = UserUtils.getUserCacheByUserId(userId);
		int userType = userCache.getUserType();
		return userType == UserType.BORROWER;
	}
	
	public static boolean isBorrowOrInverstment(long userId){
		UserCache userCache = UserUtils.getUserCacheByUserId(userId);
		int userType = userCache.getUserType();
		return userType == UserType.BORROWER || userType == UserType.INVESTMENT_BORROWER;
	}
	
	public static boolean isInvestmentBorrow(long userId){
		UserCache userCache = UserUtils.getUserCacheByUserId(userId);
		int userType = userCache.getUserType();
		return userType == UserType.INVESTMENT_BORROWER;
	}
	
	
	/**
	 * 判断是否是自然人
	 * @param userId
	 * @return
	 */
	public static boolean isNatural(long userId){
		UserCache userCache = UserUtils.getUserCacheByUserId(userId);
		int userNatural = userCache.getUserNature();
		return userNatural == UserNature.NATURAL;
	}
	
	public static boolean isCorporate(long userId){
		UserCache userCache = UserUtils.getUserCacheByUserId(userId);
		int userNatural = userCache.getUserNature();
		return userNatural == UserNature.CORPORATE_JURIDICAL;
	}
	
}
